<?php
/**
 * @version		$Id: controller.php 10869 2008-08-30 07:24:03Z willebil $
 * @package		Joomla
 * @subpackage	Content
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant to the
 * GNU General Public License, and as distributed it includes or is derivative
 * of works licensed under the GNU General Public License or other free or open
 * source software licenses. See COPYRIGHT.php for copyright notices and
 * details.
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

jimport('joomla.application.component.controller');

/**
 * Search Component Controller
 *
 * @package		Joomla
 * @subpackage	Search
 * @since 1.5
 */
class SimController extends JController
{
    /**
     * Method to show the search view
     *
     * @access	public
     * @since	1.5
     */
    function display()
    {
        JRequest::setVar('view','sims'); // force it to be the polls view
        parent::display();
    }

    /**
     * Method to view buy sim form
     *
     * @access	public
     * @since	1.5
     */
    function order()
    {
        
        JRequest::setVar('view','sim'); // force it to be the polls view
        parent::display();
    }
    /**
     * Method to save buy sim
     *
     * @access	public
     * @since	1.5
     */
    function save()
    {
        // verify info
        if(!(JRequest::getVar( 'name', 0 ) ||
                JRequest::getVar( 'tel', 0 ) ||
                JRequest::getVar( 'province ', 0 ) ||
                JRequest::getVar( 'address ', 0 ))){
                    JRequest::setVar( 'msg', 'Bạn chưa nhập đủ thông tin để chúng tôi có thể hỗ trợ bạn!' );
                    JRequest::setVar( 'view', 'sim' );
                    parent::display();
                    return;
                };

        //isNew address
        $today = date("Y-m-d H:i:s");
        JRequest::setVar( 'datetime_created', $today );
        JRequest::setVar( 'del_flag', 0 );

        // Perform the Request task
        $model = $this->getModel('sim');
        if ($model->store($post)) {
            $status = 1;
        } else {
            $status = 0;
        }
//        $this->setredirect('index.php',$msg);
        
        JRequest::setVar( 'view', 'sim' );
        JRequest::setVar( 'layout', 'form');
        parent::display();
    }
}
